<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include('../config.php');
include('../libraries/CURL.php');
include('../libraries/dao.php');
dbConnect($cfg['db']['dsn']);
function createCategory($categories,$id=0)
{
    foreach($categories as $col=>$data)
    {
        if(is_array($data))
        {
            $pid = dbInsert('INSERT INTO "categories" VALUES(null,'.$id.',\''.$col.'\',\'1\');');
            createCategory($data,$pid);
        }
        else
        {
            $domain = parse_url($data);
            dbInsert('INSERT INTO "urls" VALUES(:id,:category_id,":url", ":domain" , :frequency,:active)',
                    array(':id'=>'null',
                            ':category_id'=>$id,
                            ':url'=>$data,
                            ':domain'=>$domain['host'],
                            ':frequency'=>10,
                            ':active'=>'1'
                            )
             );
        }
    }
}
createCategory($cfg['rss']);
?>
